package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.SpecValueDao;
import com.baichang.taoshunda.entity.SpecValue;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by ${wushenglu} on 17/08/23.
 */
@Repository
public class SpecValueDaoImpl extends BaseDaoImpl<SpecValue> implements SpecValueDao {
    /**
     * 获取对应的规格值
     *
     * @param specId 规格编号
     */
    @Override
    public List<Map<String, Object>> getSpecValues(int specId) {
//        String sql = "SELECT  spec_values FROM t_spec_value WHERE spec_id=?";
        String sql = "SELECT  spec_values FROM t_spec_value WHERE type_id=?";
        return queryForMapList(sql, specId);
    }


    /**
     * 查看规格值
     *
     * @param typeId 商品规格编号
     * @return
     */
    @Override
    public List<Map<String, Object>> findGoodsSpecValue(Integer typeId) {
        String sql = " SELECT * FROM {table} WHERE type_id=? ";
        return queryForMapList(sql, typeId);
    }

    /**
     * 根据规格编号删除规格值
     *
     * @param specId 规格编号
     * @return
     */
    @Override
    public int deleteBySpecId(Integer specId) {
        return delete(" spec_id=? ", specId);
    }

    /**
     * 根据规格编号删除规格值
     *
     * @param typeId 规格编号
     * @return
     */
    @Override
    public int deleteByTypeId(Integer typeId) {
        return delete(" type_id=? ", typeId);
    }
}
